package com.qztc.news_end_core.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;

import com.qztc.news_end_dto.dto.Theme;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/theme")
@Tag(name = "新闻大类接口")
public class ThemeController {

    @Operation(summary = "查询所有新闻大类")
    @GetMapping("/get")
    public List<Theme> getTheme() {
        return new Theme().selectAll();
    }

    @Operation(summary = "添加新闻大类")
    @PostMapping("/add")
    public boolean add(@RequestBody Theme theme) {
        return theme.insert();
    }

    @Operation(summary = "删除新闻大类")
    @DeleteMapping("/deletebyid")
    public boolean delete(@RequestBody Theme theme) {
        return theme.deleteById();
    }

    @Operation(summary = "修改新闻大类")
    @PutMapping("/update")
    public boolean update(@RequestBody Theme theme) {
        UpdateWrapper<Theme> wrapper = new UpdateWrapper<>();
        wrapper.eq("themeid", theme.getThemeid());
        return theme.update(wrapper);
    }


}
